<template>
	<view class="page">
		<view class="bar_info" :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class="title_bar">
				<view class="title_bar_left" @tap.stop="handleJump" data-type="BACK">
					<image class="title_bar_left_icon" :src='STATIC_URL+"5.png"'></image>
				</view>
				<view class="title_bar_center">
					修改密码
				</view>
				<view class="title_bar_right"></view>
			</view>
		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
		<view class="set_content">
			<view class="set_list">
				<!-- <view class="list_item">
					<view class="list_item_left">手机号</view>
					<view class="list_item_right">
						<u-input v-model="security_code" :clearable="false" placeholder="请输入手机号" placeholder-style="color:#999;font-size: 26rpx;" type="number" maxlength="12" input-align="right" height="42" />
					</view>
				</view>
				<view class="list_item">
					<view class="list_item_left">验证码</view>
					<view class="list_item_right flex align-center">
						<u-input v-model="security_code" :clearable="false" placeholder="请输入验证码" placeholder-style="color:#999;font-size: 26rpx;" type="number" maxlength="6" input-align="right" height="42" />
						<benben-send-verification-code class='flex  codeLogin_fd1_1_c2' after-text='后重新获取' before-text='获取验证码' type='3' :phone="mobile"></benben-send-verification-code>
					</view>
				</view> -->
				<view class="list_item">
					<view class="list_item_left">旧密码</view>
					<view class="list_item_right">
						<u-input v-model="security_code" :clearable="false" placeholder="请输入原密码" placeholder-style="color:#999;font-size: 26rpx;" type="text" maxlength="12" input-align="right" height="42" />
					</view>
				</view>
				<view class="list_item">
					<view class="list_item_left">新密码</view>
					<view class="list_item_right">
						<u-input v-model="password" :clearable="false" placeholder="请输入新密码" placeholder-style="color:#999;font-size: 26rpx;" type="text" maxlength="12" input-align="right" height="42" />
					</view>
				</view>
				<view class="list_item no_border">
					<view class="list_item_left">确认密码</view>
					<view class="list_item_right">
						<u-input v-model="password_code" :clearable="false" placeholder="请再次输入新密码" placeholder-style="color:#999;font-size: 26rpx;" type="text" maxlength="12" input-align="right" height="42" />
					</view>
				</view>
			</view>
		</view>
		
		<view class="save_btn" @tap.stop="forgetPsd">确认修改</view>
	</view>
</template>

<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	export default {
		data() {
			return {
				mobile: "",
				security_code: "",
				password: "",
				password_code: "",
			}
		},
		onLoad() {
			
		},
		methods: {
			codeChange(e) {
				console.log(e);
			},
			// 修改登录密码  postForgetPassword
			forgetPsd() {
				if (!validate(this.security_code, 'require')) {
					this.$message.info('请输入原密码');
					return false;
				}
				// if (!validate(this.password, 'password')) {
				// 	this.$message.info('请输入6-12位字母+数字密码');
				// 	return false;
				// }
				if (!validate(this.password, 'require')) {
					this.$message.info('请输入新密码');
					return false;
				}
				if (this.password.length < 6) {
					this.$message.info('请输入至少6位的新密码');
					return false;
				}
				// if (!validate(this.password, 'password')) {
				// 	this.$message.info('请输入6-12位字母+数字新密码');
				// 	return false;
				// }
				if (!validate(this.password_code, 'require')) {
					this.$message.info('请输入确认密码');
					return false;
				}
				// if (!validate(this.password_code, 'password')) {
				// 	this.$message.info('请输入6-12位字母+数字确认密码');
				// 	return false;
				// }
				if (this.password !== this.password_code) {
					this.$message.info('新密码和确认密码不一致');
					return false;
				}
				this.$api.post(global.apiUrls.glyChangePsd, {
					old_pwd: this.security_code,
					new_pwd: this.password
				}).then(res => {
					this.$message.info(res.data.message);
					if (res.data.code == 200) {
						this.$store.commit('logout');
						setTimeout(() => {
							uni.reLaunch({
								url: '/pages/login/login'
							})
						}, 800)
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		background: url(https://www.shiyaocanyin.com/images/8.png) no-repeat #f5f5f5;
		background-size: 100% auto !important;
		.bar_info {
			width: 750rpx;
			height: 88rpx;
			overflow: hidden;
			z-index: 10;
			position: fixed;
			top: 0rpx;
		
			.title_bar {
				padding: 0 32rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
		
				.title_bar_left {
					width: 50rpx;
					.title_bar_left_icon {
						width: 18rpx;
						height: 32rpx;
					}
				}
		
				.title_bar_center {
					line-height: 88rpx;
					font-size: 36rpx;
					font-weight: 400;
				}
		
				.title_bar_right {
					width: 50rpx;
				}
			}
		}
		.set_content {
			padding: 32rpx 20rpx;
			.set_list {
				background: #fff;
				border-radius: 20rpx;
				padding: 0 32rpx;
				margin-bottom: 24rpx;
				.list_item {
					display: flex;
					align-items: center;
					justify-content: space-between;
					padding: 40rpx 0;
					border-bottom: 1rpx solid #eee;
					.list_item_left {
						font-size: 30rpx;
						width: 140rpx;
						color: #222;
					}
					.list_item_right {
						width: calc(100% - 140rpx);
						font-size: 26rpx;
						text-align: right;
					}
				}
				.no_border {
					border-bottom: 1rpx solid transparent;
				}
			}
		}
		.save_btn {
			width: 700rpx;
			height: 80rpx;
			background: #41AF36;
			border-radius: 50rpx;
			font-size: 30rpx;
			font-weight: 500;
			color: #fff;
			text-align: center;
			line-height: 80rpx;
			margin: 120rpx auto 0;
		}
	}
	.codeLogin_fd1_1_c2 {
		font-size: 26rpx;
		color: #41AF36;
		font-weight: 500;
		margin-left: 30rpx;
	}
</style>